/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-03-07     Hao       the first version
 */
#ifndef LOWPASS_FILTER_H
#define LOWPASS_FILTER_H

class LowPassFilter
{
public:
    /**
     * @param tf - Low pass filter time constant
     */
    LowPassFilter(float time_constant);
    ~LowPassFilter();

    float operator()(float x);
    float tf_; //!< Low pass filter time constant

protected:
    unsigned long timestamp_prev_; //!< Last execution timestamp
    float y_prev_;                 //!< filtered value in previous execution step
};

#endif
